package com.example.exampletest.service.impl;

import com.example.exampletest.mapper.CourseMapper;
import com.example.exampletest.model.Course;
import com.example.exampletest.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseMapper courseMapper;

    @Override
    public int addCourse(Course course) {
        return courseMapper.insert(course);
    }

    @Override
    public int updateCourse(Course course) {
        return courseMapper.update(course);
    }

    @Override
    public int deleteCourse(Long id) {
        return courseMapper.deleteById(id);
    }

    @Override
    public Course getCourseById(Long id) {
        return courseMapper.selectById(id);
    }

    @Override
    public List<Course> getAllCourses() {
        return courseMapper.selectAll();
    }

    @Override
    public List<Course> searchCourses(String keyword, Integer sortOrder) {
        return courseMapper.search(keyword, sortOrder);
    }

    @Override
    public List<Course> getCoursesByStatus(Integer status) {
        return courseMapper.selectByStatus(status);
    }

    @Override
    public List<Course> getCoursesByEnterpriseId(Integer enterpriseId) {
        return courseMapper.selectByEnterpriseId(enterpriseId);
    }

    @Override
    public int updateCourseStatus(Long id, Integer status, String auditReason) {
        return courseMapper.updateStatus(id, status, auditReason);
    }
} 